package com.ruoyi.common.core.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;
import java.util.ArrayList;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@Schema(name = "树结构实体类")
public class TreePlusEntity extends BasePlusEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    /** 父名称 */
    @Schema(description = "父名称")
    private String parentName;

    /** 父ID */
    @Schema(description = "父ID")
    private Long parentId;

    /** 显示顺序 */
    @Schema(description = "显示顺序")
    private Integer orderNum;

    /** 祖级列表 */
    @Schema(description = "祖级列表")
    private String ancestors;

    /** 子列表 */
    @Schema(description = "子列表")
    @TableField(exist = false)
    private List<?> children;

    public List<?> getChildren() {
        if (children == null) {
            children = new ArrayList<>();
        }
        return children;
    }
}
